<template>
  <a-select  v-if="options && options.length>0"
    :mode="item.mode=='group'?'default':'multiple'"
    placeholder="Please select"
    :default-value="['a1', 'b2']"
    @change="handleChange"
    @popupScroll="popupScroll"
    optionFilterProp="children"
    v-decorator="[item.key, options]"
    :style="{ display: 'inline-block'}"
  >
    <a-select-option v-for="(p,i) of options" :key="(i + 9).toString(36) + i"  :value="p.value" :label="p.text">
    </a-select-option>
  </a-select>

  <a-checkbox v-else-if="item.field_type == '6'" :default-checked="false" v-decorator="decor" />

  <a-input v-else-if="item.field_type && ['1','2','5'].indexOf(item.field_type) !== -1" :label="item.label" v-decorator="[item.key, options]" :placeholder="`请输入${item.label}`"
           :style="{ display: 'inline-block'}"/>
  <a-date-picker v-else-if="item.field_type && ['3','4'].indexOf(item.field_type) !== -1" :show-time="item.field_type==4" :label="item.label"  v-decorator="[item.key, options]" :placeholder="`请选择${item.field_type==4?'时间':'日期'}`"
           :style="{ display: 'inline-block'}"/>

<!--  v-decorator有传递和绑定问题，暂弃单独引用-->
<!--  v-decorator有传递和绑定问题，暂弃单独引用-->

</template>

<script>
    export default {
        name: "HKFormEle",
        props: {
          item:{
            type: Object,
            default: function(){
              return {};
            }
          },
          options: {
            type: Object,
            default: function(){
              return {};
            }
          },
          selectOptions: {
            type: Array,
            default: function(){
              return [];
            }
          }
        },
        methods: {
          debug(){
            console.error(JSON.stringify(this.item));
          }
        }
    }
</script>

<style scoped>

</style>
